#ifndef FLORACOMMUNITYBUS_H
#define FLORACOMMUNITYBUS_H

#include <QObject>
#include <QQueue>
#include <QMutex>
#include <QVector>
#include <QThread>
typedef std::tuple<int, int, QByteArray> commandTuple;
class FloraCommunityBus : public QThread
{
     Q_OBJECT
public:
    FloraCommunityBus();

    void setBusName(const QString &name){busName = name;}
    void updateLoopCommands(QVector<commandTuple> commands);
    virtual void appendBurstCommand(commandTuple comand);
    virtual void run();

    QVector<commandTuple> loopCommandVec;
    QQueue<commandTuple>  burstCommandQue;
    void startWork();
    void stop();
    QMutex brust_mutex;
    QMutex mutex; // 保护共享数据的互斥锁
    QString busName;
protected:
    bool running = false; // 控制线程是否运行

public:
signals:
    void loopCommandResponse(int, int, QByteArray );
    void burstCommandResponse(int , int , QByteArray);
};

#endif // FLORACOMMUNITYBUS_H
